﻿using UnityEngine;
using UnityEngine.UI;

namespace Script.UI.Component
{
    public interface IPillarGroupObjectDataProvider
    {
        float GetSliderValue();
        string GetDownText();
        string GetUpText();
    }
    
    public class PillarGroupObject : UIBase<IPillarGroupObjectDataProvider>
    {
        public Slider slider;
        public Text downText;
        public Text upText;

        protected override void OnAwake()
        {
            slider = gameObject.GetComponentInChildren<Slider>();
            var list = gameObject.GetComponentsInChildren<Text>();
            for (var i = 0; i < list.Length; i++)
            {
                if (list[i].name.Contains("moinum"))
                {
                    upText = list[i];
                }else if (list[i].name.Contains("rownum"))
                {
                    downText = list[i];
                }
            }
        }
        
        protected override void OnRefresh()
        {
            slider.value = data.GetSliderValue();
            downText.text = data.GetDownText();
            upText.text = data.GetUpText();
        }
    }
}